USE [i8office]
GO

if (exists (select * from sys.objects where name = 'proc_wkf_worksheet'))
	drop proc proc_wkf_worksheet
go
create proc proc_wkf_worksheet(
	@WorksheetID nvarchar(36),
	@TemplateMessageID nvarchar(36),
	@Document nvarchar(max)
)
as
	INSERT INTO [dbo].[WKF_Worksheet]
           ([WorksheetID]
           ,[WorksheetName]
           ,[WorkbookID]
           ,[CreateTime]
           ,[UpdateTime]
           ,[RowHeight]
           ,[ColWidth]
           ,[Document]
           ,[DataStorage]
           ,[Script]
           ,[MobileLayout]
           ,[CheckOut])
     SELECT
           @WorksheetID
           ,[WorksheetName]
           ,[WorkbookID]
           ,GETDATE()
           ,GETDATE()
           ,[RowHeight]
           ,[ColWidth]
           ,@Document
           ,[DataStorage]
           ,[Script]
           ,[MobileLayout]
           ,[CheckOut]
	FROM [dbo].[WKF_Worksheet]
	WHERE WorksheetID = (select DocHelperID from WKF_Doc where MessageID=@TemplateMessageID)